﻿Public Class frmStudentInfoAdd
    Private Sub frmStudentInfoAdd_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        cboSex.Items.Add("男")
        cboSex.Items.Add("女")
        cboMZ.Items.Add("是")
        cboMZ.Items.Add("否")
    End Sub

    Private Sub cmdXJAdd_Click(sender As Object, e As EventArgs) Handles cmdXJAdd.Click
        If Trim(txtNum.Text) = "" Then
            MsgBox("请输入学号", vbOKOnly, "警告")
            txtNum.Focus()
            Exit Sub
        End If
        If Trim(txtName.Text) = "" Then
            MsgBox("请输入姓名", vbOKOnly, "警告")
            txtName.Focus()
            Exit Sub
        End If
        If Trim(txtBirthday.Text) = "" Then
            MsgBox("请输入出生日期", vbOKOnly, "警告")
            txtBirthday.Focus()
            Exit Sub
        End If
        If Not IsDate(txtBirthday.Text) Then
            MsgBox("日期的正确格式应为(YYYY-MM-DD)", vbOKOnly, "警告")
            txtBirthday.Focus()
            Exit Sub
        End If

        If Trim(txtZY.Text) = "" Then
            MsgBox("请输入专业名称", vbOKOnly, "警告")
            txtZY.Focus()
            Exit Sub
        End If
        Dim icount As Integer
        txtSQL = "SELECT * FROM 学生 WHERE 学号 ='" & Trim(txtNum.Text) & "'"
        icount = ExecuteSQL(txtSQL, ErrorMsg)
        If icount > 0 Then
            MsgBox("学号重复,请重新输入!", vbOKOnly, "警告")
            txtNum.Focus()
        Else
            txtSQL = "INSERT INTO 学生(学号,姓名,性别,出生日期,籍贯,少数民族否,入学成绩,专业名称,简历,照片,主页)"
            txtSQL = txtSQL & "VALUES('" & txtNum.Text & "','" & txtName.Text & "','" & cboSex.Text & "','" & txtBirthday.Text & "','" & txtJG.Text & "','" & cboMZ.Text & "','" & txtScore.Text & "','" & txtZY.Text & "','" & txtResume.Text & "','" & txtphoto.Text & "','" & txtWebPage.Text & "')"
            icount = ExecuteSQL(txtSQL, ErrorMsg)
            If icount > 0 Then
                MsgBox("新增成功")
            Else
                MsgBox("新增失败")
            End If
        End If
    End Sub

    Private Sub cmdExit_Click(sender As Object, e As EventArgs) Handles cmdExit.Click
        Me.Close()
    End Sub
End Class